import { Provide} from '@midwayjs/core';
import { Transfer } from '../../entity/user/transfer';
import { InjectEntityModel } from '@midwayjs/orm';
import { Repository } from 'typeorm';


@Provide()
export class TransferService {

  @InjectEntityModel(Transfer)
  transferModel:Repository<Transfer>

  async gettransfer(ownerid: string):Promise<Transfer[]>{
    try{
      const result = await this.transferModel.find({
        where: {
          ownerid:ownerid
        }
    })
      console.log("result",result);
      return result
    }catch(err){
      console.log("err",err);
      
    }
  }
  
  async transfer(transfer:Transfer):Promise<Transfer>{
    try{
      const result = await this.transferModel.save(transfer);
      console.log("result",result);
      return result
    }catch(err){
      console.log("err",err);
      
    }
  }

  
}
